﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

namespace Amoo.WebControls
{
    public partial class Upload : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            try
            {
                DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~\\UserFiles\\" + ((Code.Entity.Usuario)Session["userSite"]).idUsuario.ToString() + "\\"));
                if (!dir.Exists){ dir.Create(); }
            }
            catch(Exception ex)
            {
               
            }

            Page.Request.Files[0].SaveAs(Server.MapPath("~\\UserFiles\\" + ((Code.Entity.Usuario)Session["userSite"]).idUsuario.ToString() + "\\") + Page.Request.Files[0].FileName.ToString().Replace(" ", "_"));
        }


        private void uploadfile()
        {
            try
            {
                if (FileUpload1.PostedFile != null)
                {
                    FileUpload1.SaveAs(Server.MapPath("~\\UserFiles\\") + "1");
                }
            }
            catch (Exception)
            {

                //throw;
            }

        }



    }
}
